/**
 * @file WeaponEvents.hpp
 * @brief 武器控制相关事件的定义
 */

#ifndef WEAPONEVENTS_HPP
#define WEAPONEVENTS_HPP

#include "EventManager.hpp"
#include "EventTypes.hpp"
#include "controller/WeaponController.hpp"

namespace WaveGuard {

    /**
     * @class WeaponEvent
     * @brief 武器事件的基类
     */
    class WeaponEvent : public Event {
    public:
        WeaponEvent(EventType type, const std::string &source = "WeaponController")
            : Event(type, source) {
        }

        std::string toString() const override {
            return Event::toString();
        }
    };

    /**
     * @class WeaponFireStartEvent
     * @brief 开始发射事件
     */
    class WeaponFireStartEvent : public WeaponEvent {
    public:
        WeaponFireStartEvent(const std::string &source = "WeaponController")
            : WeaponEvent(EventType::WEAPON_FIRE_START, source) {
        }
    };

    /**
     * @class WeaponFireStopEvent
     * @brief 停止发射事件
     */
    class WeaponFireStopEvent : public WeaponEvent {
    public:
        WeaponFireStopEvent(const std::string &source = "WeaponController")
            : WeaponEvent(EventType::WEAPON_FIRE_STOP, source) {
        }
    };

	/**
	 * @class WeaponEventControllerListener
	 * @brief 武器事件控制器监听器
	 */
    class WeaponEventControllerListener : public EventListener {
    public:
        WeaponEventControllerListener(std::shared_ptr<WeaponController> weaponController)
            : m_weaponController(weaponController) {
        }

		/**
		 * @brief 处理武器事件
		 * @param event 事件对象
		 */
        void onEvent(const std::shared_ptr<Event> &event) override {
            if (event->getType() == EventType::WEAPON_FIRE_START) {
                m_weaponController->startFiring();
            } else if (event->getType() == EventType::WEAPON_FIRE_STOP) {
                m_weaponController->stopFiring();
            }
        }

    private:
        std::shared_ptr<WeaponController> m_weaponController;
    };

} // namespace WaveGuard
#endif // !WEAPONEVENTS_HPP
